//
//  BIZFeatureCollectionViewCell.m
//  biz
//
//  Created by zhangfuwei on 2017/3/17.
//  Copyright © 2017年 jieshuibao. All rights reserved.
//

#import "BIZFeatureCollectionViewCell.h"
#import "BIZMoviePlayCategoryListDataModel.h"

@interface BIZFeatureCollectionViewCell()

@property (strong, nonatomic)  UIButton *featureButton;
@property (strong, nonatomic)  UILabel *featureLabel;

@end

@implementation BIZFeatureCollectionViewCell


-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self.contentView addSubview:self.featureButton];
        [self.contentView addSubview:self.featureLabel];
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    [self.featureButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(17);
        make.left.right.equalTo(self.contentView);
        make.height.equalTo(@48);
    }];
    
    [self.featureLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.featureButton.mas_bottom).offset(10);
        make.centerX.equalTo(_featureButton);
        make.height.equalTo(@21);
    }];
}

-(void)setCateListDataM:(BIZMoviePlayCategoryListDataModel *)cateListDataM {
    _cateListDataM = cateListDataM;
    self.featureLabel.text = cateListDataM.name;
    [self layoutIfNeeded];
}
- (void)setImageName:(NSString *)imageName {
    _imageName = imageName;
    [self.featureButton setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [self layoutIfNeeded];

}

- (void)setTitleName:(NSString *)titleName {
    _titleName = titleName;
    self.featureLabel.text = titleName;
    [self layoutIfNeeded];

}


#pragma mark -- lazyload

-(UIButton *)featureButton {
    if (!_featureButton) {
        _featureButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _featureButton.imageView.contentMode = UIViewContentModeScaleAspectFill;
        _featureButton.userInteractionEnabled = NO;
    }
    return _featureButton;
}

-(UILabel *)featureLabel {
    if (!_featureLabel) {
        _featureLabel = [UILabel new];
    }
    return _featureLabel;
}

@end
